<?php
include_once ('connection.php');
if (isset($_POST['checkType'])) {
	$count = sizeof($_POST['val']);
	$getArray = $_POST['val'];
	$getDiscountType = $_POST['checkType'];
	$setAffectedRows = array();
	for ($counter = 0; $counter < $count; $counter++) {
		$getItemID = $getArray[$counter]['id'];
		$getItemValue = $getArray[$counter]['optionValue'];
		$getDismissId = $getArray[$counter]['dismissId'];
		if ($getItemValue == "") {
			$getItemValue = 0;
		}
		if ($getDismissId == 0) {
			$sql = "update items set current_price = '" . $getItemValue . "', is_discounted='Yes' ,on_display_date = NOW() 	 where id = " . $getItemID;
		} else {
			$sql = "update items set on_display_date = NOW() 	 where id = " . $getItemID;
		}
		mysql_query($sql) or die("Couldn't condnesct to db");
		array_push($setAffectedRows, $getItemID);
	}
	echo json_encode($setAffectedRows);
}
?>